RoboTaskApp object  
Previous  Top  Next

 
There is no need to create the RoboTaskApp object when you are running or editing the script. It is created before you run the script and is available as a global object inside the script.  
 
RoboTaskApp.AddUserVariable(By Val Name as String, By Val Value as String)  
Creates a user variable with the specified "Name" and assign the specified "Value" to it.  

RoboTaskApp.Automation  
A Boolean attribute. It is available for reading and writing. It contains the value of the RoboTask automation mode.  
 
RoboTaskApp.Close  
Exits RoboTask.  
 
RoboTaskApp.DelUserVariable(By Val Name as String)  
Deletes the user variable with the specified "Name".  
 
RoboTaskApp.ExpandText(By Val Text as String)  
Expands a string containing RoboTask variables and returns the value of the string type.  
For example: the string "File c:\autoexec.bat has length {FileSize(c:\autoexec.bat)} bytes" will be turned into the string "File c:\autoexec.bat has length 153 bytes"  
 
RoboTaskApp.ExternalName(By Val ThreadID)  
Returns the "External Name" of a task by its ThreadID. You can specify an External Name on the "Advanced" tab of the task editor. You can find out the ThreadID of the current task using the GetCurrentThreadId API function. A sample use is given below.  

Declare Function GetCurrentThreadId Lib "kernel32" As Long  
 
Sub Main  
  Dim extName As String  
  extName = RoboTaskApp.ExternalName(GetCurrentThreadId)  
  MsgBox("External name is "+ extName)  
End Sub  

RoboTaskApp.Minimize  
Minimizes RoboTask into the tray icon.  
 
RoboTaskApp.Restore  
Restores the RoboTask window from the tray icon.  
 
RoboTaskApp.ServiceMode  
The attribute is read-only. It contains a Boolean value: "True" if RoboTask is running as an NT service; "False" if RoboTask is running as a regular Windows application.  
 
RoboTaskApp.SetUserVariable(By Val Name as String, By Val Value as String)  
Sets the value of the "Name" user variable to the specified "Value"  
 
RoboTaskApp.StartTask(By Val ExternalName as String)  
Starts the task with the specified "External Name".  
 
RoboTaskApp.StopTask(By Val ExternalName as String)  
Stops the task with the specified "External Name".  
 
RoboTaskApp.TaskCount  
The read-only attribute of the numerical type. Returns the number of tasks registered in RoboTask.  
 
RoboTaskApp.TaskEnabled(By Val ExternalName as String)  
A Boolean attribute available for reading and writing. Allows you to read or set the "Enabled" parameter of the task with the specified "ExternalName".  
For example:  
RoboTaskApp.TaskEnabled("Check_email") = False  
 
RoboTaskApp.TaskInfo(By Val NumTask as Long, ExtName as String, Name as String, ID as Long)  
Sets the properties of the task with the specified number ("NumTask").  
ExtName – External Name;  
Name – task name;  
ID – internal numerical identifier.  
This method is used to enumerate all tasks and extract the parameter of each task. A sample use is given below.  
 
Declare Function GetCurrentThreadId Lib "kernel32" As Long  
 
Sub Main  
    Dim cnt As Long  
    Dim nam As String  
    Dim extNam As String  
    Dim id As Long  
    Dim i As Long  
 
    cnt = RoboTaskApp.TaskCount  
    RoboTaskApp.WriteToLog(1,"Total "+Str(cnt)+" tasks",GetCurrentThreadId)  
 
    For i  = 0 To cnt - 1  
        RoboTaskApp.TaskInfo(i,extNam,nam,id)  
        RoboTaskApp.WriteToLog(1,extNam+"; "+nam+"; "+Str(id),GetCurrentThreadId)  
    Next  
End Sub  

RoboTaskApp.Version  
A read-only attribute of the string type. Contains the version number of RoboTask in it.  
 
RoboTaskApp.WHandle  
A read-only attribute of the Long type. Contains the Handle of the main RoboTask window. This value is necessary for some Windows API functions to work properly (for example, SendMessage, PostMessage).  
 
RoboTaskApp.WriteToLog(By Val MsgType as Integer, By Val MessageStr as String, By Val ThreadID as Long)  
Records a message to the task log. To record a message to the system log of RoboTask, you should set the TreadID to 0.  
MsgType – message type: 0 – regular message, 1 – warning, 2 – error;  
MessageStr – message string  
ThreadID – the Thread ID of the current task. It can be obtained using the GetCurrentThreadId API function. If you set it to 0, the message will be recorded to the system log of RoboTask.  
A sample use is given below.  
 
Declare Function GetCurrentThreadId Lib "kernel32" As Long  
 
Sub Main  
  Dim thr As Long  
  thr = GetCurrentThreadId  
  RoboTaskApp.WriteToLog(1, "Hello World", thr)  
End Sub  
 
 
note Related Topics  
Evaluate  
Basic script  
Also see Basic help